package com.itheima.youdianda.controller;


import com.itheima.youdianda.common.R;
import com.itheima.youdianda.pojo.SysMenu;
import com.itheima.youdianda.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * 张凯
 */
@RestController
@RequestMapping("/sys_menu")
public class SysMenuController {

    @Autowired
    private SysMenuService sysMenuService;

    @PostMapping("/update")
    public R update(@RequestBody SysMenu sysMenu){
        sysMenuService.updateMenu(sysMenu);
        return R.success(null);

    }

    @RequestMapping("allData")
    public R allMenus(){
        return sysMenuService.allMenus();
    }

    @PostMapping("/add")
    public  R addMenu(@RequestBody SysMenu sysMenu){

        sysMenuService.addMenu(sysMenu);
        return R.success(null);
    }

    @GetMapping("/rowInfo")
    public R rowInfo(@RequestParam Integer id){
        return sysMenuService.getInfo(id);
    }

    @GetMapping("del")
    public R delete(@RequestParam Integer id){
           sysMenuService.deleteMenu(id);
        return R.success(null);
    }


}
